﻿using Mt.Site.Core.ContentManagement.Entities;
using Mt.Site.Core.ContentManagement.Values;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Mt.Site.Core.ContentManagement
{
    public interface IContentFrontendManager
    {
        #region 泛型

        /// <summary>
        /// 详情（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="id">数据id</param>
        /// <returns></returns>
        Task<T> GetContentByIdAsync<T>(long id) where T : new();

        /// <summary>
        /// 详情预览（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="id">数据id</param>
        /// <returns></returns>
        Task<T> GetContentByIdPreaViewAsync<T>(Guid id) where T : new();


        /// <summary>
        /// 根据Guid 获取 AuxiliaryId
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<long> GetLongIdAsync(Guid id);

        /// <summary>
        /// 分页（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="queryMethod"></param>
        /// <param name="skipCount"></param>
        /// <param name="getCount"></param>
        /// <returns></returns>
        Task<PagedContent<T>> GetContentListByPagedAsync<T>(
            Func<IQueryable<Content>, IQueryable<Content>> queryMethod,
            int skipCount,
            int getCount) where T : new();

        /// <summary>
        /// 不分页（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="queryMethod"></param>
        /// <returns></returns>
        Task<List<T>> GetAllContentAsync<T>(Func<IQueryable<Content>, IQueryable<Content>> queryMethod, int maxCount = 0) where T : new();

        #endregion

        Task<Dictionary<string, object>> GetAsync(long id);


        /// <summary>
        /// 浏览量+1
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<int> UpdatePv(long id);

        /// <summary>
        /// 获取上一页下一页（返回 id）
        /// </summary>
        /// <param name="sorting"></param>
        /// <param name="menuId"></param>
        /// <param name="relateId"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PreAndNextItemId> GetPreAndNextLink(string sorting, long menuId, Guid? relateId, Guid id);

        /// <summary>
        /// 排序
        /// </summary>
        /// <param name="sorting">"Name asc,Id desc"</param>
        /// <param name="q"></param>
        /// <returns></returns>
        IQueryable<Content> GetOrderedQuery(string sorting, IQueryable<Content> q);


    }
}
